﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script>

        var myNums=new Array();
        var numbers = new Array(1,2,3,4,5,6,7,8,9,0);

    function KeyDesign()
    {
        getRNDNumber();
        
        document.all.numPad.c1.value = getRNDNumber();
        document.all.numPad.c2.value = getRNDNumber();
        document.all.numPad.c3.value = getRNDNumber();
        document.all.numPad.c4.value = getRNDNumber();
        document.all.numPad.c5.value = getRNDNumber();
        document.all.numPad.c6.value = getRNDNumber();
        document.all.numPad.c7.value = getRNDNumber();
        document.all.numPad.c8.value = getRNDNumber();
        document.all.numPad.c9.value = getRNDNumber();
        document.all.numPad.c0.value = " "+myNums[0]+" ";
        
        //var randomnumber=Math.floor(Math.random()*11)
//        document.all.numPad.c1.value = myNums[1];
//        document.all.numPad.c2.value = myNums[2];
//        document.all.numPad.c3.value = myNums[3];
//        document.all.numPad.c4.value = myNums[4];
//        document.all.numPad.c5.value = myNums[5];
//        document.all.numPad.c6.value = myNums[6];
//        document.all.numPad.c7.value = myNums[7];
//        document.all.numPad.c8.value = myNums[8];
//        document.all.numPad.c9.value = myNums[9];
//        document.all.numPad.c0.value = myNums[10];
//        //alert(getRNDNumber() );
    }
    
    function numContains(a, obj) {
  var i = a.length;
  while (i--) {
    if (a[i] === obj) {
      return true;
    }
  }
  return false;
}

Array.prototype.remove = function(from, to) {
  var rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  return this.push.apply(this, rest);
};

    
    function getRNDNumber()
    {
            var randomnumber=Math.floor(Math.random()*numbers.length);
            var num = numbers[randomnumber]
            myNums[myNums.length] = num;
            numbers.remove(randomnumber);
            return " "+num+" ";
    
//        for (x=0; x<11; x++)
//        {
//            var randomnumber=Math.floor(Math.random()*10)
//            if (numContains(myNums,randomnumber) && randomnumber<10)
//                {
//                    x--;
//                }
//                else
//                {
//                    myNums[x] = randomnumber;
//                }
//        } 
//        //return randomnumber;
    }
    
    Array.prototype.contains = function(obj) {
  var i = this.length;
  while (i--) {
    if (this[i] === obj) {
      return true;
    }
  }
  return false;
}

    function contains1()
    {
    if (!Array.indexOf)
        {
        Array.indexOf = [].indexOf ?
      function (arr, obj, from) { return arr.indexOf(obj, from); }:
      function (arr, obj, from) { // (for IE6)
        var l = arr.length,
            i = from ? parseInt( (1*from) + (from<0 ? l:0), 10) : 0;
        i = i<0 ? 0 : i;
        for (; i<l; i++) {
          if (i in arr  &&  arr[i] === obj) { return i; }
        }
        return -1;
      };
    }
    }

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
</script>
</HEAD>

<BODY onload="KeyDesign();">
<form action="" method="post" class="" name="numPad">
<table cellpadding="2" cellspacing="2" border="0">
<tr>
     <td colspan="3" align="center"><input type="text" name="quantity" size="20"></td>
</tr>
<tr>
     <td><input name="c1" type="button" value="  1  " style="font-size:25px;" onclick = "document.numPad.quantity.value =document.numPad.quantity.value+ trim(this.value,' ')"></td>
     <td><input name="c2" type="Button" value="  2  " style="font-size:25px;" onclick = "document.numPad.quantity.value =document.numPad.quantity.value+ trim(this.value,' ')"></td>
     <td><input name="c3" type="Button" value="  3  " style="font-size:25px;" onclick = "document.numPad.quantity.value =document.numPad.quantity.value+ trim(this.value,' ')"></td>
</tr>
<tr>
     <td><input name="c4" type="Button" value="  4  " style="font-size:25px;" onclick = "document.numPad.quantity.value =document.numPad.quantity.value+ trim(this.value,' ')"></td>
     <td><input name="c5" type="Button" value="  5  " style="font-size:25px;" onclick = "document.numPad.quantity.value =document.numPad.quantity.value+ trim(this.value,' ')"></td>
     <td><input name="c6" type="Button" value="  6  " style="font-size:25px;" onclick = "document.numPad.quantity.value =document.numPad.quantity.value+ trim(this.value,' ')"></td>
</tr>
<tr>
     <td><input name="c7" type="Button" value="  7  " style="font-size:25px;" onclick = "document.numPad.quantity.value =document.numPad.quantity.value+ trim(this.value,' ')"></td>
     <td><input name="c8" type="Button" value="  8  " style="font-size:25px;" onclick = "document.numPad.quantity.value =document.numPad.quantity.value+ trim(this.value,' ')"></td>
     <td><input name="c9" type="Button" value="  9  " style="font-size:25px;" onclick = "document.numPad.quantity.value =document.numPad.quantity.value+ trim(this.value,' ')"></td>
</tr>
<tr>
     <td></td>
     <td><input name="c0" type="Button" value="  0  " style="font-size:25px;" onclick = "document.numPad.quantity.value =document.numPad.quantity.value+ trim(this.value,' ')"></td>
     <td></td>
</tr>
</table>
</form>

</BODY>
</HTML>